package com.authine.cloudpivot.app.openapi.domain;

import com.authine.cloudpivot.app.openapi.domain.gateway.DynamicRouteGateway;
import com.authine.cloudpivot.app.openapi.dto.domainmodel.GatewayRouteDefinition;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * @author carter
 * create_date  2020/6/3 15:58
 * description     路由的领域模型
 */
@Data
@ApiModel("路由领域实体")
@Component
public class Route {

    private final DynamicRouteGateway dynamicRouteGateway;

    public Route(DynamicRouteGateway dynamicRouteGateway) {
        this.dynamicRouteGateway = dynamicRouteGateway;
    }


    @ApiModelProperty("路由定义")
    private GatewayRouteDefinition gatewayRouteDefinition;

    @ApiOperation("增加路由")
    public String addRoute(GatewayRouteDefinition route) {
        return dynamicRouteGateway.add(route);
    }

    @ApiOperation("更新路由")
    public String updateRoute(GatewayRouteDefinition route) {
        return dynamicRouteGateway.update(route);
    }

    @ApiOperation("删除路由")
    public String deleteRoute(String routeId) {
        return dynamicRouteGateway.delete(routeId);
    }

    @ApiOperation("查询路由")
    public List<Route> listRoute() {
        return Collections.emptyList();
    }


}
